package com.mall.db.api;

import com.mall.db.mapper.UmsResourceCategoryMapper;
import com.mall.domain.UmsResource;
import com.mall.domain.UmsResourceCategory;
import com.mall.interface1.api.UmsResourceCategoryApi;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;

@DubboService
public class UmsResourceCategoryApiImpl implements UmsResourceCategoryApi {
    @Autowired
    private UmsResourceCategoryMapper mapper;
    @Override
    public void save(UmsResourceCategory umsResourceCategory) {
        if(umsResourceCategory.getCreateTime()==null){
            umsResourceCategory.setCreateTime(LocalDateTime.now());
        }
        mapper.insert(umsResourceCategory);
    }

    @Override
    public void delete(Integer id) {
        mapper.deleteById(id);
    }

    @Override
    public List<UmsResourceCategory> listAll() {
        return mapper.selectList(null);
    }

    @Override
    public void update(UmsResourceCategory umsResourceCategory) {
        mapper.updateById(umsResourceCategory);
    }
}
